package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.view.View;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.db.table.DepartmentTable;

import java.util.List;

/**
 * @author lj
 */
public class CreateDepteSelectAdapter extends CommonRecycleAdapter<DepartmentTable> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener commonClickListener;

    public CreateDepteSelectAdapter(Context context, List<DepartmentTable> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.adapter_dept_select_item);
        this.mContext = context;
        this.commonClickListener = commonClickListener;
    }

    @Override
    public void bindData(CommonViewHolder holder, DepartmentTable data, int position) {

        holder.setText(R.id.tv_left, data.getDeptCode());
        holder.setText(R.id.tv_right, data.getDeptName());
        holder.setCommonClickListener(commonClickListener);

        View view = holder.getView(R.id.ll_dept_select_item);
        if (data.isCheck()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.red));
        } else {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
    }
}
